package com.loong.nnm.controller;

import com.loong.nnm.entity.netconf.NetconfBuilderParameters;
import com.loong.nnm.services.NetconfToolServices;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class NetconfToolController {
    /**
     * 服务对象
     */
    @Resource
    NetconfToolServices netconfToolServices;

    /**
     * 创建Netconf连接
     * @param parameters 连接参数
     * @return 返回连接状态
     */
    @RequestMapping("/establish")
    public int createNetconfConnection(@RequestBody NetconfBuilderParameters parameters){
        System.out.println(parameters);
       System.out.println("创建连接调用");
       return  netconfToolServices.createConnection(parameters);
    }

    /**
     * 获取连接状态
     * @param node 操作节点
     * @return 连接状态
     */
    @GetMapping("/status/{node}")
    public boolean getConnectionStatus(@PathVariable String node){
        System.out.println("创建连接调用"+node);
        return  netconfToolServices.getConnectionStatus(node);
    }

    @PostMapping("/close/{node}")
    public void setClose(@PathVariable String node){
        System.out.println("创建连接调用"+node);
        netconfToolServices.close(node);
    }

    @RequestMapping("/node/{node}/create_subscription")
    public String createSubscription(@PathVariable String node){
        return netconfToolServices.createSubscription(node);
    }

/*    @GetMapping("/node/{node}/me")
    public String getMe(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetMe(node);
    }*/

/*    @GetMapping("/node/{node}/eqs")
    public String getEqs(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetEqs(node);
    }

    @GetMapping("/node/{node}/ptps")
    public String getPtps(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetPtps(node);
    }

    @GetMapping("/node/{node}/ftps")
    public String getFtps(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetFtps(node);
    }

    @GetMapping("/node/{node}/ctps")
    public String getCtps(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetCtps(node);
    }

    @GetMapping("/node/{node}/connections")
    public String getConnections(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetConnections(node);
    }

    @GetMapping("/node/{node}/alarms")
    public String getAlarms(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetAlarms(node);
    }

    @GetMapping("/node/{node}/alarms/masks")
    public String getAlarmMasks(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetAlarmsMasks(node);
    }

    @GetMapping("/node/{node}/tcas")
    public String getTcas(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetTcas(node);
    }

    @GetMapping("/node/{node}/tcas/parameters")
    public String getTcaParameters(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetTcasParameters(node);
    }

    @GetMapping("/node/{node}/pgs")
    public String getPGs(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetPGs(node);
    }

    @GetMapping("/node/{node}/lags")
    public String getLAGs(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetLAGs(node);
    }

    @GetMapping("/node/{node}/performances")
    public String getPerformances(@PathVariable String node){
        System.out.println(node);
        return netconfToolServices.netconfGetPerformances(node);
    }

    @GetMapping("/node/{node}/performances/current")
    public String getCurrentPerformances(@PathVariable String node,@RequestBody TcaParameter tcaParameter){
        System.out.println(node);
        return netconfToolServices.netconfGetCurrentPerformances(node,tcaParameter);
    }

    @RequestMapping("/node/{node}/performances/current")
    public String currentPerformances(@PathVariable String node,@RequestBody TcaParameter tcaParameter){
        System.out.println(node);
        System.out.println("=============================================");
        System.out.println(tcaParameter);
        System.out.println("=============================================");
        return netconfToolServices.netconfGetCurrentPerformances(node,tcaParameter);
    }*/




}
